package cn.kp.learning.service.Impl;
import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.kp.learning.dao.CoreUserOrgDao;
import cn.kp.learning.model.CoreUserOrg;
import cn.kp.learning.model.CoreUserOrgExample;
import cn.kp.learning.model.CoreUserOrgExample.Criteria;
import cn.kp.learning.service.CoreUserOrgService;
@Service("cuoService")
public class CoreUserOrgServiceImpl implements CoreUserOrgService {
	@Resource
	private CoreUserOrgDao cuoDao;
	@Override
	public int addCuo(CoreUserOrg cuo) {
		int insertResult = 0;
		CoreUserOrgExample ce = new CoreUserOrgExample();
		Criteria criteria = ce.createCriteria();
		criteria.andOrgCompanyIdEqualTo(cuo.getOrgCompanyId());
		criteria.andOrgDepartmentEqualTo(cuo.getOrgDepartmentId());
		criteria.andOrgOfficeEqualTo(cuo.getOrgOfficeId());
		criteria.andOrgGroupEqualTo(cuo.getOrgGroupId());
		criteria.andUserNameEqualTo(cuo.getUserName());
		List<CoreUserOrg> lt = cuoDao.selectByExample(ce);
		if(lt.size()>0){
			
		}else{
			insertResult = cuoDao.insertSelective(cuo);
		}
		return insertResult;
	}

	@Override
	public int deleteCuo(CoreUserOrg cuo) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int updateCuo(CoreUserOrg cuo) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<CoreUserOrg> getCuoList(CoreUserOrgExample example) {
		// TODO Auto-generated method stub
		return cuoDao.selectByExample(example);
	}

	@Override
	public CoreUserOrg getCuo(HashMap<String, Object> hm) {
		// TODO Auto-generated method stub
		return cuoDao.selectByPrimaryKey(1);
	}

	@Override
	public int countCuo(CoreUserOrgExample example) {
		// TODO Auto-generated method stub
		return 0;
	}

}
